import random

def guess_number():
    number = random.randint(1, 100)
    attempts = 0

    print("猜数字游戏: 请猜一个1-100之间的整数,你有10次机会")
    while attempts < 10:
        user_guess = int(input("请猜一个数："))
        attempts += 1

        if user_guess < number:
            print("猜小了")
        elif user_guess > number:
            print("猜大了")
        else:
            print(f"恭喜你，猜对了, 用了{attempts}次")
            break
    else:
        print(f"你失败了，正确答案是{number}")

guess_number()